#include <iostream>
#include <algorithm> 
using namespace std;

const int N = 110;
struct st{
	int score;
	string name;
}st[N];
bool cmp(struct st s1,struct st s2)
{
	return s1.score > s2.score;
}
int main()
{
	int n;
	cin >> n;
	for(int i = 0;i<n;i++)
	{
		cin >> st[i].score >> st[i].name;	
	}
	sort(st,st+n,cmp);
	cout << st[0].name << endl;
}
